package day01;

/**
 * @author yzh
 * @desc TODO
 * @date 2025/4/8
 */

/*public class Test02 {
    public static void main(String[] args) {
        int x = 2;
        {
            int y = 6;
            System.out.println("x is " + x);
            System.out.println("y is " + y);
        }
        y = x; // 变量y是在代码块内部声明的，不能再代码块外部直接访问
        System.out.println("x is " + x);
    }
}*/

public class Test04 {
    public static void main(String[] args) {
        int x = 2;
        int y; // 变量y声明在代码块外部，作用域为整个main方法
        {
            y = 6;
            System.out.println("x is " + x);
            System.out.println("y is " + y);
        }
        y = x;
        System.out.println("x is " + x);
    }
}
